import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2023-10-30
 * Time:9:20
 */
public class test {
    //求n的阶乘
    public static int fun(int x) {
        if (x != 0) {
            return x*fun(x-1);
        }
        else {
            return 1;
        }
    }
    //求阶乘的和
    public static int funsum(int x) {

        int mulsum = 0;
        for (int j = 1;j <= x;j++) {
            int mul = 1;
            for (int i = 1; i <= j; i++) {
                mul *= i;
            }
            mulsum += mul;
        }
        return mulsum;
    }

    public static void main1(String[] args) {
        int n = 0;
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        int a = fun(n);
        System.out.println(a);
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int ret = funsum(a);
        System.out.println(ret);
    }
    //求斐波那契数列第n项（递归实现）
    public static int fpnk(int n) {
        if (n != 1 && n != 2) {
            return fpnk(n-1) + fpnk(n-2);
        }
        else {
            return 1;
        }
    }

    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = fpnk(n);
        System.out.println(m);
    }
    //在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值
    public static int max(int x,int y) {
        return x>=y ? x : y;
    }

    public static double max(double x,double y,double z) {
        return (x >= y ? x : y) > z ? (x >= y ? x : y) : z;
    }

    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x = scanner.nextDouble();
        double y = scanner.nextDouble();
        double z = scanner.nextDouble();
        double ret = max(x,y,z);
        System.out.println(ret);
    }

    public static int add(int x,int y) {
        return x+y;
    }

    public static double add(double x,double y,double z) {
        return x+y+z;
    }

    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x = scanner.nextDouble(),y = scanner.nextDouble(),z = scanner.nextDouble();
        System.out.println(add(x,y,z));
    }

    //递归按顺序打印1234
    public static void PrintInOrder(int x) {
        if (x < 10) {
            System.out.println(x % 10);
            return;
        }
        PrintInOrder(x / 10);
        System.out.println(x % 10);
    }

    public static void main6(String[] args) {
        int a = 1234;
        PrintInOrder(a);
    }

    //递归求1+2+...+n
    public static int sum(int n) {
        if (n > 1) {
            return n + sum(n-1);
        }
        else {
            return 1;
        }
    }

    public static void main7(String[] args) {
        System.out.println(sum(100));
        System.out.println(sum(20));
    }

    //递归求一个数各位之和
    public static int persum(int n) {
        if (n < 10) {
            return n;
        }
        return n % 10 + persum(n / 10);
    }

    public static void main(String[] args) {
        System.out.println(persum(234566));
    }
}
